package com.dmj.sqldsl.model.column;

import java.util.Optional;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;

@Builder
@AllArgsConstructor
@EqualsAndHashCode(doNotUseGetters = true)
public class SimpleColumn implements Column {

  private final String tableId;

  private String fieldName;

  @Getter
  private final String columnName;

  public Optional<String> getTableId() {
    return Optional.ofNullable(tableId);
  }

  @Override
  public String getFieldName() {
    return Optional.ofNullable(fieldName).orElse(columnName);
  }
}
